﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace iReaper.IndexService.Common
{
    public static class EventType
    {
        public static Guid WWE { get { return g_IdTbl["WWE"]; } }
        public static Guid Channel9 { get { return g_IdTbl["Channel9"]; } }

        private static Dictionary<string, Guid> g_IdTbl;

        static EventType()
        {
            g_IdTbl = new Dictionary<string,Guid>();
            var assembly = System.Reflection.Assembly.GetAssembly(typeof(EventType));
            using (var strm = assembly.GetManifestResourceStream("iReaper.IndexService.Common.EventType.xml"))
            {
                System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
                xmldoc.Load(strm);

                var xmlTypes = xmldoc.SelectNodes("//Type");
                foreach (XmlNode n in xmlTypes)
                {
                    string name = n.Attributes["name"].Value;
                    Guid guid = new Guid(n.InnerText);
                    g_IdTbl.Add(name, guid);
                }
            }
        }
    }
}
